package io.renren.modules.task.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.task.entity.MtCcEquipmentEntity;
import io.renren.modules.task.service.MtCcEquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-23 09:03:45
 */
@RestController
@Api(description = "设备操作API")
@RequestMapping("generator/mtccequipment")
public class MtCcEquipmentController {
    @Autowired
    private MtCcEquipmentService mtCcEquipmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:mtccequipment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mtCcEquipmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:mtccequipment:info")
    public R info(@PathVariable("id") Long id){
		MtCcEquipmentEntity mtCcEquipment = mtCcEquipmentService.getById(id);

        return R.ok().put("mtCcEquipment", mtCcEquipment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:mtccequipment:save")
    public R save(@RequestBody MtCcEquipmentEntity mtCcEquipment){
		mtCcEquipmentService.save(mtCcEquipment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:mtccequipment:update")
    public R update(@RequestBody MtCcEquipmentEntity mtCcEquipment){
		mtCcEquipmentService.updateById(mtCcEquipment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mtccequipment:delete")
    public R delete(@RequestBody Long[] ids){
		mtCcEquipmentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 全部操作台信息
     */
    @GetMapping("/get/all/console")
    @ApiOperation(value = "全部操作台信息", notes = "全部操作台信息")
//    @RequiresPermissions("")
    public R getAllConsole(){
        List<MtCcEquipmentEntity> list = mtCcEquipmentService.getAllConsole();
        return R.ok().put("list",list);
    }

}
